package com.cqie.rbac.controller;

import com.cqie.rbac.service.IQuotaService;
import com.cqie.rbac.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Author 夏兵
 * @Date 2021/10/11
 */
@RestController
@Api(tags = "指标操作")
@RequestMapping("/quota")
public class QuotaController {

    @Autowired
    private IQuotaService iQuotaService;

    @PostMapping("/excelImport")
    @ApiOperation("指标导入")
    public Result excelImportQuota (MultipartFile file) throws IOException {
        iQuotaService.excelImportQuota(file.getInputStream());
        return Result.ok();
    }

    @GetMapping("/treeOfQuota")
    @ApiOperation("指标树形数据")
    public Result treeOfQuota() {
        return iQuotaService.treeOfQuota();
    }

    @GetMapping("/queryOptionsByQuotaId")
    @ApiOperation("根据指标id查询选项")
    public Result queryOptionsByQuotaId(Integer quotaId) {
        return iQuotaService.queryOptionsByQuotaId(quotaId);
    }
}
